CC = g++
CPPFLAGS = -Wall

all: parser

clean:
	rm -rf parser.cpp parser.hpp tokens.cpp parser library/*.o

parser.cpp: parser.y
	bison -d -o $@ $^

parser.hpp: parser.cpp

tokens.cpp: tokens.l parser.hpp
	flex -o $@ $^

parser: parser.cpp tokens.cpp main.cpp library/node.o library/operand.o library/operatorunary.o library/operatorbinary.o library/variable.o library/vector.o library/assignment.o library/call.o library/instance.o library/basetype.o library/return.o library/declarationvariable.o library/block.o library/conditional.o library/loop.o library/declarationfunction.o library/program.o library/empty.o library/type.o
	g++ -o $@ $^

tests: parser
	for filename in $$(ls inputs); do echo -n "$$filename "; cat "inputs/$$filename" | ./parser 1 && echo 'OK'; done

basic: parser
	cat "inputs/00-basic.c" | ./parser 1 && echo 'OK'
